package de.lot.action;

import de.lot.model.Position;
import de.lot.model.StudentLearningOutcome;
import de.lot.model.Trait;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.framework.EntityHome;

/**
 * Class to interact between front- and backend.
 *
 * @see Position
 * @author Stefan Kohler <kohler.stefan@gmail.com>
 */
@Name("positionHome")
public class PositionHome extends EntityHome<Position> {

    @In(create = true)
    StudentLearningOutcomeHome studentLearningOutcomeHome;
    @Out(required = false)
    private Trait trait;

    /**
     * Associates the position to a StudentLearningOutcome
     */
    public void wire() {
        StudentLearningOutcome slo = studentLearningOutcomeHome.getDefinedInstance();
        if (slo != null) {
            getInstance().setStudentLearningOutcome(slo);
        }
    }

    public void writeIt() {
        System.out.println(getTrait().getName());
    }

    /**
     * @return the trait
     */
    public Trait getTrait() {
        return trait;
    }

    /**
     * @param trait the trait to set
     */
    public void setTrait(Trait trait) {
        this.trait = trait;
    }
}
